import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types';

const DirectionCountMeta: IPublicTypeComponentMetadata = {
  componentName: 'DirectionCount',
  title: '消防告警',
  category: '基础组件',
  group: '消防安全',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: 'hzdz-charts',
    version: '0.1.0',
    exportName: 'DirectionCount',
    main: 'src/index.tsx',
    destructuring: true,
    subName: ''
  },
  props: [
    {
      name: 'ref',
      propType: 'object',
    },
    {
      name: 'key',
      propType: 'string',
    },
    {
      name: 'style',
      propType: 'object',
    },
  ],
  configure: {
    props: [
      // 基础配置
      {
        name: 'basic',
        type: 'group',
        display: 'accordion',
        title: {
          label: '基础配置',
        },
        items: [
          {
            name: 'direction',
            title: {
              label: '方向文字',
              tip: '显示的方位文字'
            },
            setter: 'StringSetter'
          },
          {
            name: 'count',
            title: {
              label: '数量值',
              tip: '显示的数量'
            },
            setter: {
              componentName: 'MixedSetter',
              props: {
                setters: [
                  'NumberSetter',
                  'StringSetter'
                ]
              }
            }
          },
          {
            name: 'unit',
            title: {
              label: '单位',
              tip: '数量的单位'
            },
            setter: 'StringSetter'
          },
          {
            name: 'directionColor',
            title: {
              label: '文字颜色',
              tip: '文字的颜色'
            },
            setter: 'ColorSetter'
          },
          {
            name: 'backgroundColor',
            title: {
              label: '背景颜色',
              tip: '背景颜色，支持多个颜色配置渐变'
            },
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ColorSetter',
                  initialValue: 'rgba(52,165,255,0.39)'
                }
              }
            }
          },
          {
            name: 'spacing',
            title: {
              label: '间距',
              tip: '数字与单位之间的间距'
            },
            setter: 'NumberSetter'
          },
          {
            name: 'countFontSize',
            title: {
              label: '文字大小',
              tip: '数字文字的大小'
            },
            setter: 'NumberSetter'
          }
        ]
      }
    ],
    supports: {
      style: true,
      className: true,
      events: ['onClick']
    }
  }
};

const snippets: IPublicTypeSnippet[] = [
  {
    title: '消防告警',
    screenshot: '',
    schema: {
      componentName: 'DirectionCount',
      props: {
        direction: '西',
        count: 844,
        unit: '个',
        colorScheme: ['#4D74FF', '#5AF3B8', '#93DBFF'],
        data: [
          { name: '设备报警', value: 10, color: '#4D74FF' },
          { name: '人品报警', value: 20, color: '#5AF3B8' },
          { name: '119联动', value: 30, color: '#93DBFF' }
        ],
        directionColor: 'rgba(255,255,255,0.8)',
        backgroundColor: [
          'rgba(52,165,255,0)',
          'rgba(52,165,255,0.39)',
          'rgba(52,165,255,0.45)',
          'rgba(52,165,255,0.35)',
          'rgba(0,139,255,0)'
        ],
        spacing: 4,
        countFontSize: 17
      }
    }
  }
];

export default {
  ...DirectionCountMeta,
  snippets,
};
